
const { app, dialog } = require("electron")

const MainMenu = [
    {
        label: '基础',
        submenu: [
            { role: 'reload', label: '刷新' },
            {
                accelerator: 'CmdOrCtrl+Shift+R',
                label: '重启', click: () => {
                    app.relaunch()
                    app.exit()
                }

            },
            { "role": "quit", label: '退出', accelerator: 'CmdOrCtrl+Q' },
            { type: "separator" },
            {
                label: '关于', click: () => {
                    dialog.showMessageBox({
                        title: '关于',
                        message: 'QQ1744358454 流光科技版权所有',
                        type: 'info',
                    })
                },
                accelerator: 'CmdOrCtrl+Shift+A',

            }

        ]
    },
    {
        label: '功能',
        submenu: [
            {
                label: '功能窗口', accelerator: 'CmdOrCtrl+O', click: () => {
                    if (!mainWindowChild) {
                        createWindowChild()
                    }
                    if (!mainWindowChildinstance) {
                        mainWindowChild.show()
                        mainWindowChildinstance = mainWindowChild
                    }
                }
            },
        ]
    },
];

function setMenumainWindow(Menu, Window, template) {
    const menu = Menu.buildFromTemplate(template);
    Window.setMenu(menu);
}


module.exports = {
    setMenumainWindow,
    MainMenu
}